<template>
	<view>
		<view class="home_tab">
			<view class="home_tab_title">
				<view class="title_inner">
					<uni-segmented-control :values="items.map(v=>v.title)" :current="current" @clickItem="onClickItem" style-type="text"
					 active-color="#d4237a"></uni-segmented-control>
				</view>
				<view class="iconfont icon-sousuo"></view>
			</view>
			<view class="home_tab_content"></view>
		</view>
		<view v-if="current === 0">
			<!-- 推荐模块暂时注释<home-recommend></home-recommend> -->
			<home-new></home-new>
		</view>
		<view v-if="current === 1">
			<home-classification></home-classification>
		</view>

	</view>

</template>

<script>
	import homeRecommend from "./home-recommend"
	import homeNew from "./home-new"
	import homeClassification from "./home-classification"
	import {
		uniSegmentedControl
	} from "@dcloudio/uni-ui"
	export default {
		components: {
			homeRecommend,
			homeNew,
			uniSegmentedControl,
			homeClassification
		},
		data() {
			return {
				items: [{
					title: "最新"
				}, {
					title: "分类"
				}],
				current: 0
			}
		},
		methods: {
			onClickItem(e) {
				if (this.current != e.currentIndex) {
					this.current = e.currentIndex;
				}
			}
		}
	}
</script>

<style lang="scss">
	.home_tab {
		.home_tab_title {
			position: relative;

			.title_inner {
				width: 60%;
				margin: 0 auto;
			}

			.icon-sousuo {
				position: absolute;
				top: 50%;
				transform: translateY(-50%);
				right: 5%;
			}
		}

		.home_tab_content {}
	}
</style>
